package com.xiawu;

import java.io.*;

public class Test9 {
    public static void main(String[] args) throws Exception {
        // 多线程拷贝
        File from = new File("D:\\java\\from");
        File to = new File("D:\\java\\to");
        File[] files = from.listFiles(); // 获取所有的视频文件对象
        for(File fi : files){
            // 启动线程
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        BufferedInputStream bin =  new BufferedInputStream(new FileInputStream(fi));
                        File fto = new File(to,fi.getName());
                        BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(fto));
                        byte b[] = new byte[1024];
                        int n = bin.read(b);
                        while(n!=-1){
                            bout.write(b,0,n);
                            n = bin.read(b);
                        }
                        bout.close();
                        bin.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();

        }



    }
}
